
# 此示例示意函数调用运算符() 的重载

class MySum:
    def __init__(self, init_value=0):
        self.data = init_value
    def __call__(self, *args, **kwargs):
        print('args:', args)
        self.data += sum(args)
        return self.data
s = MySum(100)  # 创建了一个对象，内部的初始值为100
result = s(1, 2, 3, 4)  # ???
print(result)  # 110
result = s(10, 20, 30, 40)  #
print(result)  # 210